import 'package:flutter/material.dart';
import 'package:haitao_app/haitao.dart';
import 'package:haitao_app/home.dart';
import 'package:haitao_app/hours.dart';

class TagNavigator extends StatelessWidget{

  GlobalKey<NavigatorState> globalKey;
  String name;

  TagNavigator({this.globalKey,this.name});

  @override
  Widget build(BuildContext context) {

    var build=_widgetBuild(context);
    // TODO: implement build
    return Navigator(
        key: globalKey,
        initialRoute: name,
        onGenerateRoute: (setting){
          print(setting);
          return MaterialPageRoute(
              builder:(context)=> build[setting.name](context)
          );
        },
    );
  }

  Map<String,WidgetBuilder> _widgetBuild(BuildContext context){
    return {
      NavigatorName.index:(context)=>Home(),
      NavigatorName.haitao:(context)=>Haitao(),
      NavigatorName.hours:(context)=>Hours(),
    };
  }

}

class NavigatorName{
  static const String index="index";
  static const String haitao="haitao";
  static const String hours="hours";

}